<template>
	<div>
		<el-tabs v-model="activeName" @tab-click="handleTabChange">
			<el-tab-pane v-for="(item, index) in tabsList" :key="index" :label="item.label" :name="item.value"></el-tab-pane>

			<div class="content-card">
				<component
					v-if="!loading"
					class="pd10"
					:is="whickComm[activeName]"
					@refresh="handleRefresh"
					:nowRowData="nowRowData"
					:actionBtn="false"
					:searchConfig="false"
					:key="activeName"
					:isWithAuth="0"
					:soleKey="`dpServiceObject-${nowRowData.idCard}`"
				></component>
			</div>
		</el-tabs>
	</div>
</template>

<script setup lang="ts">
import BaseDetail from './BaseDetail/index.vue'
import BlockchainInfo from './BlockchainInfo/index.vue'
import { useCommonStore } from '@/stores/common'

const { setMoreSearch } = useCommonStore()

const whickComm = {
	BaseDetail,
	BlockchainInfo,
}
type Props = {
	nowRowData?: any
	isBlockchain?: boolean
}
const props = withDefaults(defineProps<Props>(), {
	isBlockchain: false,
})
const emit = defineEmits(['refresh', 'rechange'])

const activeLabelTitle = ref('基础信息')
const loading = ref(false)
const tabsList: any = [
	{ label: '基础信息', value: 'BaseDetail' },
	{ label: '打卡上链信息', value: 'BlockchainInfo' },
]
const activeName = ref('BaseDetail')
provide('nowRowData', props.nowRowData)

const handleRefresh = () => {
	emit('refresh')
}
const handleTabChange = (tab) => {
	activeLabelTitle.value = tab.props.label
	setMoreSearch({
		params: {
			idCard: props.nowRowData.idCard,
			creditCode: props.nowRowData.creditCode,
		},
	})
}

onUnmounted(() => {
	setMoreSearch({})
})
</script>

<style scoped></style>
